package com.jQueryAjax.controller;

import javax.swing.text.html.HTML;

import com.jfinal.core.Controller;
import com.jfinal.render.ContentType;

public class AjaxController extends Controller {

	public void jsTest(){
		renderText("这是AjaxController返回的数据！");
	}
	public void getHtml(){
		String username = getPara("username");
		String content = getPara("content");
		renderText("<div class='panel panel-primary'><div class='panel-heading'>"+username
				+"</div><div class='panel-body'>"+content+"</div></div>");
	}
	public void getXml(){
		String username = getPara("username");
		String content = getPara("content");
		//因为后面jQuery在返回数据中要使用.find("comment")命令，则这必须在comment外面套一层标签，否则无法访问，血的教训！
		renderText("<root><comment username = '"+username+"'><content>"+content+"</content></comment></root>");
	}
	public void getJson(){
		String username = getPara("username");
		String content = getPara("content");
		renderText("{\"username\":\""+username+"\",\"content\":\""+content+"\"}");
	}
	public void formSerialize(){
		String username = getPara("username");
		String password = getPara("password");
		String info = getPara("info");
		renderText("<b>用户名：</b>"
				+username+"<br><b>密码：</b>"
				+password+"<br><b>个人信息：</b>"
				+info);

	}
	public void formJs(){
		String username = getPara("username");
		String password = getPara("password");
		String content = getPara("content");
/*		renderText("<root><b>用户名："
				+username+"</b><b>密码："
				+password+"</b><b>个人信息："
				+content+"</b></root>");*/
		renderHtml("<b>用户名：</b>"
				+username+"<br><b>密码：</b>"
				+password+"<br><b>个人信息：</b>"
				+content);
		
	}


}
